﻿using System;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities;

namespace HCMS.IServices
{
    /// <summary>
    /// 应用服务 接口 基础
    /// </summary>
    public interface ICommonAppService<TDbContext, TEntity> : IApplicationService where TEntity : class, IEntity<int>
    {
        #region GetAllAsync 获取全部
        /// <summary>
        /// 获取全部
        /// </summary>
        /// <returns></returns>
        Task<IQueryable<TEntity>> GetAllAsync();
        #endregion

        #region BaseFirstOrDefaultAsync 获取对象
        /// <summary>
        /// 获取对象
        /// </summary>
        /// <param name="expression">条件表达式</param>
        /// <returns></returns>
        Task<TEntity> BaseFirstOrDefaultAsync(Expression<Func<TEntity,bool>> expression);
        #endregion

        #region BaseInsertAsync 添加
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        Task<TEntity> BaseInsertAsync(TEntity entity);
        #endregion

        #region BaseUpdateAsync 更新
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        Task<TEntity> BaseUpdateAsync(TEntity entity);
        #endregion

    }
}
